<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a href="">演示</a>
                <a>
                    <cite>导航元素</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" autocomplete="off" placeholder="开始日" name="start" id="start">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" autocomplete="off" placeholder="截止日" name="end" id="end"></div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="username" placeholder="请输入用户名" autocomplete="off"
                                   class="layui-input"></div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" lay-submit="" lay-filter="sreach">
                                <i class="layui-icon">&#xe615;</i></button>(待)
                        </div>
                    </form>
                </div>
                <div class="layui-card-body ">
                    <table class="layui-hide" id="taskTable" lay-filter="taskTable"></table>
                    <script type="text/html" id="taskData">
                        <div class="layui-btn-container">
                            <button class="layui-btn addTask"><i class="layui-icon">&#xe654;</i>添加任务</button>
                        </div>
                    </script>

                    <script type="text/html" id="taskBar">
                        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑(待)</a>
                        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除(待)</a>
                    </script>

                </div>
            </div>
        </div>
    </div>
</div>
</body>

<script>layui.use('laydate',
    function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });

    });</script>
<script>layui.use('table',
    function () {
        var table = layui.table;

        layui.use('table', function () {
            var table = layui.table;

            table.render({
                elem: '#taskTable'
                , url: '/admin/tasks'
                , toolbar: '#taskData' //开启头部工具栏，并为其绑定左侧模板
                , defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                    title: '提示'
                    , layEvent: 'LAYTABLE_TIPS'
                    , icon: 'layui-icon-tips'
                }]
                , page: true
                , title: '员工数据表'
                , curr: 1
                , limit: 8
                , limits: [5, 8, 10, 12, 14]
                , cols: [[
                    /*{type: 'checkbox', fixed: 'left'}*/
                    {field: 'taskId', title: 'ID', width: 100, fixed: 'left', unresize: true, sort: true}
                    , {field: 'taskName', title: '任务名称', width: 200}
                    , {field: 'taskContent', title: '任务内容', width: 450}
                    , {field: 'taskAdmin', title: '发布者', width: 150}
                    , {field: 'taskStartTime', title: '发布时间', width: 180}
                    , {field: 'taskAndTime', title: '结束时间', width: 180}
                    , {field: 'status', title: '任务状态', width: 150,templet: function(res){
                        return res.status=='0'?'<em>进行中</em>':'<em>已结束</em>'
                      }}
                    , {fixed: 'right', title: '操作', toolbar: '#taskBar', width: 200}
                ]]
            });


            //监听行工具事件
            table.on('tool(taskTable)', function (obj) {
                var data = obj.data;
                if (obj.event === 'del') {
                    /*layer.confirm('真的删除行么', function (index) {
                        $.ajax({
                            type:"delete",
                            url:"/employee/emp",
                            data:{
                                empId:data.empId
                            },
                            dataType:"json",
                            success:function (res) {
                                if (res.code==0){
                                    layer.msg("删除员工成功")
                                } else {
                                    layer.msg("删除员工失败")
                                }
                            },
                            error:function (res) {
                                layer.msg("你没有权限")
                            }
                        })
                        layer.close(index);
                    });*/
                } else if (obj.event === 'edit') {
                    /*var index = layer.open({
                        type: 2,
                        area: [$(window).width() * 0.7 + 'px', $(window).height() - 100 + 'px'],
                        fix: false, //不固定
                        maxmin: true,
                        shadeClose: true,
                        shade: 0.4,
                        title: "修改员工",
                        content: "./emp-edit.html",
                        success: function () {
                            var childIframe = layer.getChildFrame('body');
                            childIframe.find("input[name='empId']").val(obj.data.empId)
                            childIframe.find("input[name='empName']").val(obj.data.empName)
                            childIframe.find("select[name='roleId']").attr("title", obj.data.roles[0].roleId)
                            childIframe.find("input[name='age']").val(obj.data.age)
                            childIframe.find("input[value=" + obj.data.sex + "]").attr("checked", "checked")
                            childIframe.find("input[name='phone']").val(obj.data.phone)
                            childIframe.find("input[name='address']").val(obj.data.address)
                            obj.data.isDel == 0 ?
                                childIframe.find("input[name='isDel']").attr("checked", true) : childIframe.find("input[name='isDel']").attr("checked", false)
                        }
                    })*/
                }
            });
        });


        $(".addTask").click(function () {
            var index = layer.open({
                        type: 2,
                        area: [$(window).width() * 0.7 + 'px', $(window).height() - 100 + 'px'],
                        fix: false, //不固定
                        maxmin: true,
                        shadeClose: true,
                        shade: 0.4,
                        title: "添加任务",
                        content: "./task-add.html",
                        success: function () {

                        }
                    })



        })












    });</script>


</html>